<!DOCTYPE html>
<html>
<head>
    <title>添加版位</title>
    <include file='public/head'>
</head>
<body>
	<!-- 内容开始 -->
	<div class="layui-tab">
		<!-- 表单开始 -->
		<form class="layui-form" action="" id="da">

			<input type="hidden" name="edit[id]" value="{$data.id}">

			<div class="layui-form-item">
				<label class="layui-form-label">输入框</label>
				<div class="layui-input-inline" >
					<input type="text" name="edit[title]" required  lay-verify="title" placeholder="请输入标题" autocomplete="off" class="layui-input" value="{$data.title}">
				</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label">密码框</label>
				<div class="layui-input-inline">
					<input type="password" name="edit[password]" required  lay-verify="pass"  placeholder="请输入密码" autocomplete="off" class="layui-input" value="{$data.password}">
				</div>
				<div class="layui-form-mid layui-word-aux">辅助文字</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label">城市</label>
				<div class="layui-input-inline">
					<select name="edit[city]" lay-verify="required">
						<option value="">请选择...</option>
						<option value="1" <if condition="$data['city'] eq 1" >selected="selected"</if>>杭州</option>
						<option value="2" <if condition="$data['city'] eq 2" >selected="selected"</if>>台州</option>
					</select>
				</div>
			</div>
			
			<div class="layui-form-item">
				<label class="layui-form-label">复选框</label>
				<div class="layui-input-block">
					<input type="checkbox" name="edit[likes][write]" title="写作">
					<input type="checkbox" name="edit[likes][read]" title="阅读" checked>
					<input type="checkbox" name="edit[likes][dai]" title="发呆">
				</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label">开关</label>
				<div class="layui-input-block">
					<input type="checkbox" name="edit[switch]" lay-skin="switch" ay-text="开启|关闭" <if condition="$data['switch'] eq 1">checked</if> >
				</div>
			</div>

			<div class="layui-form-item layui-form-text">
				<label class="layui-form-label">文本域</label>
				<div class="layui-input-block">
					<textarea name="content" placeholder="请输入内容" lay-verify="content" class="layui-textarea">{$data.content}</textarea>
				</div>
			</div>
	  	</form>
		<!-- 表单结束 -->
	</div>
	<!-- 内容结束 -->
	<include file='public/scripts'>
		
	<script type="text/javascript">

	/**
	 * 子页面方法
	 */
	function callbackdata(index){
		var dara = $("#da").serialize();
		let editpage_url = "{:cmf_plugin_url('Demo://admin_index/edit')}";

		$.ajax({
			url:editpage_url,
			type:'post',
			data:dara,
			success:function(data){
				let icon = ( data.code == 200 )  ? 1 : 5 ; 
					layer.msg( data.message , { time:1200 , icon:icon },function(){
						if(icon = 1){
							parent.layer.close(index);//关闭弹框
							window.parent.location.reload(index);//刷新父页
						}	
					});
			},
			error:function(data){
				console.log(data);
				layer.msg('修改失败');
				return false;
			}
		})
	}    

	</script>
</body>
</html>

